﻿<%@ Page Language="C#" MasterPageFile="~/News.Master" AutoEventWireup="true" CodeBehind="DownloadDriver.aspx.cs"
    Inherits="ProjectQuaDep.DownloadDriver" %>

<%@ Register Src="/Control/Download/PaddingSearch.ascx" TagName="PaddingSearch" TagPrefix="uc1" %>
<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="ContentPlaceHolder1">
    <div class="listdownload">
        <div class="titlelistdownload">
            <input type="text" value="Tìm kiếm theo từ khóa" onfocus="InputFocusDL('Tìm kiếm theo từ khóa',this)"
                onblur="InputBlurDL('Tìm kiếm theo từ khóa',this)" onkeypress="return SearchKeyPressDL(event)"
                class="txt-search" id="txtSearch">
            <img src="/Images/search.png" onclick="return OnSearchClickDL()" />
        </div>
        <div class="title-download">
            THƯ VIỆN HỒNG THỦY
        </div>
        <h2 class="rsdownload">
            Kết quả tìm kiếm từ khóa: <b>
                <asp:Literal ID="ltTitleSearch" runat="server"></asp:Literal></b></h2>
        <div class="showlistdownload">
            <ul>
                <asp:Literal ID="ltListNews" runat="server"></asp:Literal>
            </ul>
        </div>
        <div class="pagedownload">
            <uc1:PaddingSearch ID="PaddingSearch1" runat="server" />
        </div>
    </div>
    <script>
        function InputFocusDL(textdefault, control) {
            text = control.value;
            if (text == textdefault) control.value = "";
        }

        function InputBlurDL(textdefault, control) {
            text = control.value;
            if (text == "") control.value = textdefault;
        }
        function SearchKeyPressDL(event) {
            var textSearch = document.getElementById('txtSearch');
            var strSearch = textSearch.value;
            var url = "";
            var key;
            if (window.event) {
                key = window.event.keyCode;
                if (key == 13) {
                    if (textSearch.value != "") {
                        strSearch = strSearch.replace('?', '').replace(/"/g, '').replace(/^\s+|\s+$/g, '');
                        if (strSearch == "") return false;
                        else if (strSearch.indexOf("?") != -1) return false;
                        strSearch = encodeURIComponent(strSearch);
                        url = "/thu-vien-download.htm?KeySearch=" + strSearch + "&PageIndex=1";
                        document.location.href = url;
                        event.keyCode = 0;
                        return false;
                    }
                    else {
                        alert("Bạn chưa nhập từ khóa tìm kiếm !");
                        return false;
                    }
                }
            }
            else {
                key = event.which;
                if (key == 13) {
                    if (textSearch.value != "") {
                        strSearch = strSearch.replace('?', '').replace(/"/g, '').replace(/^\s+|\s+$/g, '');
                        if (strSearch == "") return false;
                        else if (strSearch.indexOf("?") != -1) return false;
                        strSearch = encodeURIComponent(strSearch);
                        url = "/thu-vien-download.htm?KeySearch=" + strSearch + "&PageIndex=1";
                        window.location.href = url;
                        return false;
                    }
                    else {
                        alert("Bạn chưa nhập từ khóa tìm kiếm !");

                        return false;
                    }

                }
            }
        }
        function OnSearchClickDL() {
            var textSearch = document.getElementById('txtSearch');
            if (textSearch.value != "") {
                var strSearch = textSearch.value;
                strSearch = strSearch.replace('?', '').replace(/"/g, '').replace(/^\s+|\s+$/g, '');
                if (strSearch == "") return false;
                else if (strSearch.indexOf("?") != -1) return false;
                strSearch = encodeURIComponent(strSearch)
                url = "/thu-vien-download.htm?KeySearch=" + strSearch + "&PageIndex=1";
                if (document.all) {
                    window.location.href = url;
                }
                else {
                    document.location.href = url;
                }
                return false;
            }
            else {
                alert("Bạn chưa nhập từ khóa tìm kiếm!");
                return false;
            }
        }
        function PopupWindowCenter(URL, title, w, h) {
            var left = (screen.width / 2) - (w / 2);
            var top = (screen.height / 2) - (h / 2);
            var newWin = window.open(URL, title, 'toolbar=no, location=no,directories=no, status=no, menubar=no, scrollbars=no, resizable=no,copyhistory=no, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
        }
    </script>
</asp:Content>
